function displayInfo(item) {
	$.ajax({
		url: "infouser",
		type: "post",
		data: {login:[item]},
		dataType: "json",
		success: function(user) {
			if(user.hasPwd) {
				$('#pwd').attr('disabled', 'disabled');
				$('#pwd').addClass("disabled");
				$('#pwd_verif').attr('disabled', 'disabled');
				$('#pwd_verif').addClass("disabled");
				$("#info-user").html(user.nom + " " + user.prenom + " a déjà un password.");
			} else {
				$('#pwd').removeAttr('disabled');
				$('#pwd').removeClass("disabled");
				$('#pwd_verif').removeAttr('disabled');
				$('#pwd_verif').removeClass("disabled");
				$("#info-user").html(user.nom + " " + user.prenom + " n'a pas de password, il faut lui en attribuer un.");
			}
		},
		error: function(e,xhr) {
			alert("Cet utilisateur n'existe pas.");
		}
	});
}

function removeInfo() {
	$("#info-user").html("");
	$('#pwd').attr('disabled', 'disabled');
	$('#pwd').addClass("disabled");
	$('#pwd_verif').attr('disabled', 'disabled');
	$('#pwd_verif').addClass("disabled");
}

function pwdOk(data) {
	if(data.length == 0) {
		$('#pwd-ok').html("");
	} else if(data.length > 5) {
		$('#pwd-ok').html("<img style='width:16 px; height: 16px' src='/css/main/images/icons/tick.png'/>");
	} else {
		$('#pwd-ok').html("<img style='width:16 px; height: 16px' src='/css/main/images/icons/cross.png'/>");
	}
}

function verifPwdOk(data) {
	if(data.length == 0) {
		$('#pwd-verif-ok').html("");
	} else if(data == $('#pwd').val()) {
		$('#pwd-verif-ok').html("<img style='width:16 px; height: 16px' src='/css/main/images/icons/tick.png'/>");
	} else {
		$('#pwd-verif-ok').html("<img style='width:16 px; height: 16px' src='/css/main/images/icons/cross.png'/>");
	}
}

$(document).ready(function() {
	Disabled('pwd');
	Disabled('pwd_verif');
});